package com.zx.idc.backend.gui.sys;


import com.baomidou.mybatisplus.plugins.Page;
import com.zx.idc.backend.gui.common.BasicBaseApi;
import com.zx.idc.backend.gui.common.Result;
import com.zx.idc.backend.gui.common.base.BaseExcelApi;
import com.zx.idc.ds.sys.entity.SysMediaTrustDomains;
import com.zx.idc.ds.sys.service.ISysMediaTrustDomainsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 多媒体信任域名表 前端控制器
 * </p>
 *
 * @author jianlong_java
 * @since 2019-07-05
 */
@RestController
@RequestMapping("/api/sysMediaTrustDomains")
public class SysMediaTrustDomainsController extends BasicBaseApi<ISysMediaTrustDomainsService, SysMediaTrustDomains> implements BaseExcelApi<ISysMediaTrustDomainsService, SysMediaTrustDomains> {

    @GetMapping("/query-page")
    @RequiresPermissions("system-configuration:sys-media-trust-domains")
    public Result<Page<SysMediaTrustDomains>> page(Page<SysMediaTrustDomains> page, SysMediaTrustDomains sysMediaTrustDomains) {
        return success(service.pageByParam(page, sysMediaTrustDomains));
    }

    @PostMapping("/delete/batchDomains")
    @RequiresPermissions("system-configuration:sys-media-trust-domains:edit")
    public Result<Boolean> deleteBatchDomains(@RequestBody List<String> domainList) {
        if (domainList.isEmpty()) {
            return success(true);
        }
        return success(service.deleteBatchDomains(domainList));
    }

    @GetMapping("/deleteByDomain/{domain}")
    @RequiresPermissions("system-configuration:sys-media-trust-domains:edit")
    public Result<Boolean> deleteByDomain(@PathVariable String domain) {
        return success(service.deleteByDomain(domain));
    }

}

